<%--
  Created by IntelliJ IDEA.
  User: 雷神
  Date: 2021/4/7
  Time: 11:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <base href="<%=basePath%>">
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="view/bootstrap-3.3.5/css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="view/bootstrapvalidator/css/bootstrapValidator.css" />
    <script charset="utf-8" src="view/jquery/jquery-1.10.2.min.js"></script>
    <script charset="utf-8" src="view/bootstrap-3.3.5/js/bootstrap.js"></script>
    <script charset="utf-8" src="view/bootstrapvalidator/js/bootstrapValidator.js"></script>
</head>
<body>
<div class="container">
    <div class="row">
        <h2>购买资产修改页面</h2>

        <form action="zcgm/update" id="fm1"
              class="form-horizontal" method="post" role="form">
            <div class="col-md-10">
                <table class="table table-hover" id="myTable">

                    <tbody>
                    <tr>

                        <td colspan="4" class="success">购买资产修改页面
                            <input type="hidden" name="oid" value="${gm.oid }"/>

                        </td>
                    </tr>
                    <tr>
                        <td>申请单号</td>
                        <td><input type="text" class="form-control" name="docNo"
                                   id="docNo" value="${gm.docNo }" readonly></td>
                        <td>单据类型</td>
                        <td><input type="text" class="form-control" name="doctype"
                                   id="doctype" value="${gm.doctype }" readonly></td>
                    </tr>
                    <tr>
                        <td>部门</td>
                        <td><select class="form-group" name="deptid" id="deptid">
                            <option value="">请选择部门</option>
                            <c:forEach items="${deptlist }" var="d">
                                <c:if test="${gm.deptid==d.oid}">
                                    <option value=" ${d.oid }" selected>${d.deptName}</option>
                                </c:if>
                                <c:if test="${gm.deptid!=d.oid}">
                                    <option value=" ${d.oid }">${d.deptName}</option>
                                </c:if>
                            </c:forEach>
                        </select></td>
                        <td>申请人</td>
                        <td>
                            <select id="semp" class="form-group" name="proposer">
                                <option value="">请选择申请人</option>
                                <c:forEach items="${emplist }" var="emp">
                                    <c:if test="${gm.proposer==emp.oid}">
                                        <option value=" ${emp.oid }" selected>${emp.empName}</option>
                                    </c:if>
                                    <c:if test="${gm.proposer!=emp.oid}">
                                        <option value=" ${emp.oid }">${emp.empName}</option>
                                    </c:if>
                                </c:forEach>
                            </select>
                        </td>

                    </tr>
                    <tr>

                        <td>创建人</td>
                        <td><input type="text" class="form-control"
                                   value="admin" readonly> <input
                                type="hidden" value="1" name="creator"/></td>
                        <td>
                            审批流程
                        </td>
                        <td>
                            <select  class="form-group" name="flowid">
                                <option value="">请选择审批流程</option>
                                <c:forEach items="${lclist }" var="lc">
                                    <c:if test="${gm.flowid==lc.oid}">
                                        <option value="${lc.oid }" selected>${lc.flowName}</option>
                                    </c:if>
                                    <c:if test="${gm.flowid!=lc.oid}">
                                        <option value="${lc.oid }">${lc.flowName}</option>
                                    </c:if>
                                </c:forEach>
                            </select>
                        </td>


                    </tr>
                    <tr>
                        <td>采购原因</td>
                        <td><input type="text" value="${gm.reason }" name="reason"
                                   id="reason" class="form-group"></td>
                        <td>备注</td>
                        <td><input type="text" value="${gm.remark }" name="remark"
                                   class="form-group"></td>
                    </tr>

                    <tr>
                        <td colspan="4" class="success">资产移动明细
                            <button type="button" onclick="Inserttable()"
                                    class="btn btn-primary">添加报销明细
                            </button>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <hr>
            <div class="row" id="updatebx">
                <c:forEach items="${gm.zcgmmx }" var="gmmx">
                    <div class="col-md-12">
                        <label class="col-md-2">资产名称</label>
                        <div class="col-md-3">
                          <input type="text" value="${gmmx.assetName}" name="assetName">
                        </div>

                        <label class="col-md-2">序列号</label>
                        <div class="col-md-3">
                            <input type="hidden" name="mxoid" value="${gmmx.oid}">
                            <input type="text" value="${gmmx.assetNumber}" name="assetNumber">
                        </div>
                    </div>

                    <div class="col-md-12">
                        <label class="col-md-2">规格</label>
                        <div class="col-md-3">
                            <input type="text" value="${gmmx.guige}" name="guige">
                        </div>

                        <label class="col-md-2">申购数量</label>
                        <div class="col-md-3">
                            <input type="hidden" name="mxoid" value="${gmmx.oid}">
                            <input type="text" value="${gmmx.shengou}" name="shengou">
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="col-md-2">单价</label>
                        <div class="col-md-3">
                            <input type="text" value="${gmmx.unitPrice}" name="unitPrice">
                        </div>

                        <label class="col-md-2">数量</label>
                        <div class="col-md-3">
                            <input type="text" value="${gmmx.quantity}" name="quantity">
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="col-md-2">
                            <button type="button" onclick="remove(this)" class="btn btn-primary">删除</button>
                        </div>
                    </div>
                </c:forEach>
            </div>
            <button type="submit" class="btn btn-primary">确认修改</button>
        </form>
    </div>
</div>
<div id="demodiv" class="form-group" style="display: none">
    <div class="col-md-12">
        <label class="col-md-2">资产名称</label>
        <div class="col-md-3">
            <input type="text" name="assetName" class="form-control">
        </div>

        <label class="col-md-2">序列号</label>
        <div class="col-md-3">
            <input type="text" class="form-control" name="assetNumber">
        </div>
    </div>
    <div class="col-md-12">
        <label class="col-md-2">规格说明</label>
        <div class="col-md-3">
            <input type="text" class="form-control" name="guige">
        </div>

        <label class="col-md-2">申购数量</label>
        <div class="col-md-3">
            <input type="text" class="form-control" name="shengou">
        </div>
    </div>
    <div class="col-md-12">
        <label class="col-md-2">单价</label>
        <div class="col-md-3">
            <input type="text" class="form-control" name="unitPrice">
        </div>

        <label class="col-md-2">数量</label>
        <div class="col-md-3">
            <input type="text" class="form-control" name="quantity">
        </div>
    </div>

    <div class="col-md-12">
        <div class="col-md-2">
            <button type="button" onclick="remove(this)" class="btn btn-primary">删除</button>
        </div>
    </div>

</div>


</body>

<script type="text/javascript">
    function Inserttable() {
        var demodiv = $("#demodiv").clone(true);
        demodiv.attr("id", "");
        demodiv.show();
        demodiv.appendTo($("#updatebx"));
    }

    function remove(r) {
        $(r).parent().parent().parent().remove();
    }

    // zcyd/selectjl
    $("#deptid").change(function () {

        $.getJSON("zcyd/selectjl", {deptid: $("#deptid").val()}, function (msg) {
            console.log(msg)
            var emp = $("#semp")[0];
            emp.options.length = 1;
            for (var i = 0; i < msg.length; i++) {
                var emp1 = msg[i];
                emp.options.add(new Option(emp1.empName, emp1.oid));
            }
        });
    });

</script>
</html>
